package Object;

public class ObjectDemo {
    public static void main(String[] args) {
        Point p = new Point(100,200);
        System.out.println(p);
        System.out.println(p.toString());//重写方法看对象
        String str = "这是一个点:"+p;//java中任何类型与字符串的连接结果都是字符串
        //实际上JVM也是调用toString()方法将其转换成字符串了
        System.out.println(str);
       Point p1 = new Point(100,200);//只要new就会创建新的对象
       Point p2 = new Point(100,200);//只要new就会创建新的对象
       System.out.println(p1==p2);//比较的是对象地址不是值
       System.out.println(p1.equals(p2));//内部还在比较地址  //通常需要重写equals()方法来比较属性值
       String s1= new String ("hello");
       String s2= new String ("hello");
       System.out.println(s1.equals(s2));
       StringBuilder stringbuilder1= new StringBuilder("hello");
       StringBuilder stringbuilder2= new StringBuilder("hello");
       System.out.println(stringbuilder1.equals(stringbuilder2));//StringBuilder没有重写equals()方法
       System.out.println(s1.equals(stringbuilder1));//String和StringBuilder不能相互比较     类型不同



    }
}
